﻿#pragma once


#include <QObject>
#include <QSemaphore>
#include <QDebug>
#include <QTimer>

#include <opencv.hpp>
#include "include/dh/dhconfigsdk.h"
#include "include/dh/dhnetsdk.h"


class Camera : public QObject
{
	Q_OBJECT

public:
	Camera(int id);
	~Camera();

	void snap();
	void busy(bool state);
private:

	void init_sdk();
	void login();
	static void SnapRev(LLONG lLoginID, BYTE* pBuf, UINT RevLen, UINT EncodeType, DWORD CmdSerial, LDWORD dwUser);
	fDisConnect DisConnectFunc(LLONG lLoginID, char* pchDVRIP, LONG nDVRPort, LDWORD dwUser);
	void elapsed(QString msg);
	void print_error(QString msg);

	int camera_id = 1;
	std::string camera_ip;

	QSemaphore* g_semaphore;
	bool _busy = 0;
	uint g_nCmdSerial = 0;

	bool g_bNetSDKInitFlag = false;
	LLONG g_lLoginHandle = 0;
	uint camera_width = 1920, camera_height = 1080;

	std::vector<std::string> camera_errs; //错误列表
	QElapsedTimer g_counter;

	QTimer g_timer;

signals:
	void sign_snap_rev(cv::Mat img);

};

